﻿@model AdventureWorks.Entities.Customer

@{
	ViewBag.Title = String.Format("[ {0} ]", Model.FullName);
}

<h2>Edit @Model.FullName</h2>

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>Customer</legend>

		@Html.HiddenFor(model => model.ID)
		@Html.HiddenFor(model => model.PasswordHash)
		@Html.HiddenFor(model => model.PasswordSalt)
		@Html.HiddenFor(model => model.ModifiedDate)

        <div class="editor-label">
            @Html.LabelFor(model => model.Title)
        </div>
        <div class="editor-field">
			@Html.DropDownList("Titles", String.Empty)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.FirstName)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.FirstName)
            @Html.ValidationMessageFor(model => model.FirstName)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.MiddleName)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.MiddleName)
            @Html.ValidationMessageFor(model => model.MiddleName)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.LastName)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.LastName)
            @Html.ValidationMessageFor(model => model.LastName)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Suffix)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Suffix)
            @Html.ValidationMessageFor(model => model.Suffix)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.CompanyName)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.CompanyName)
            @Html.ValidationMessageFor(model => model.CompanyName)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.SalesPerson)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.SalesPerson)
            @Html.ValidationMessageFor(model => model.SalesPerson)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.EmailAddress)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.EmailAddress)
            @Html.ValidationMessageFor(model => model.EmailAddress)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.Phone)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.Phone)
            @Html.ValidationMessageFor(model => model.Phone)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.ModifiedDate)
        </div>
        <div class="editor-field">
            @Html.DisplayFor(model => model.ModifiedDate)
        </div>
		<br />
		
		 
			<fieldset>
				<legend>Addresses</legend>
				<p>@Html.ActionLink("New Address", "../Address/Create", new { CustomerID = Model.ID }) - 
				@Html.ActionLink("Manage Addresses", "../Address/Index", new { CustomerID = Model.ID })</p>
				
				@foreach (var address in Model.Addresses)
				{
					@Html.Partial("_DetailAddresses", address)
					
				}
			</fieldset>
		 

        <p>
            <input type="submit" value="Save" />
        </p>
    </fieldset>
}

<div>
	@Html.ActionLink("Back to List", "Index")
</div>
